package com.twu.biblioteca;

import java.util.Scanner;

public class ControllerMenu {

    private Scanner scanner = new Scanner(System.in);
    private Biblioteca biblioteca = new Biblioteca();

    public void chooseTheAction() {
        String userOption = scanner.next();

        do {
            if (userOption.equals("0")) {
                System.out.println(biblioteca.showTheBooksOnTheLibrary());
                System.out.println(biblioteca.showTheMoviesOnTheLibrary());
            } else if (userOption.equals("1")) {
                System.out.print("Type the book number to checkout: ");
                System.out.println(biblioteca.checkOutBook(scanner.nextInt()));
                break;
            } else if (userOption.equals("2")) {
                Book bookReturning = new Book();
                System.out.print("Name book: ");
                bookReturning.setName(scanner.nextLine());
                System.out.print("\nAuthor: ");
                bookReturning.setAuthor(scanner.nextLine());
                System.out.print("\nYear published: ");
                bookReturning.setYearPublished(scanner.nextInt());
                System.out.println(biblioteca.returnBook(bookReturning));
                break;
            } else if (userOption.equals("3")) {
                User user = new User();
                System.out.print("Inform your number of registration: ");
                user.setRegistration(scanner.next());

                System.out.println("Inform your password: ");
                user.setPassword(scanner.next());

                System.out.print("Type the movie number to checkout: ");
                System.out.println(biblioteca.checkOutMovie(scanner.nextInt(), user));
                break;
            } else if (userOption.equals("4"))
                break;
            else {
                System.out.println("Select a valid option! Type again.");
            }
            userOption = scanner.next();
        } while (!userOption.equals("4"));

    }
}
